home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 783 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.1 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: sdouglas@armltd.co.uk (scott douglass)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Two questions about declarations in condit
  5. Date: 19 Mar 1996 09:44:41 PST
  6. Organization: Apple Computer, Inc.
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <sdouglas-1903961328250001@193.131.176.202>
  9. References: <sdouglas-1403961511110001@193.131.176.202> <4ikkbu$b5u@engnews1.Eng.Sun.COM>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: Tue, 19 Mar 1996 13:28:24 +0000
  12. X-Newsreader: Yet Another NewsWatcher 2.0.2
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMU7ynky4NqrwXLNJAQHR3QIAnH9ds+gFv4doPimMkHgeiwzwUdTWT33y
  15.     hUZBBoUKEvUpXMYeN1JaT8alNrrfOx8FcWc+15soQW8EUM+f0qLsvQ==
  16.     =3qbt
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. In article <4ikkbu$b5u@engnews1.Eng.Sun.COM>, clamage@Eng.Sun.COM wrote:
  20.  
  21. : In article 1403961511110001@193.131.176.202, sdouglas@armltd.co.uk
  22. : (scott douglass) writes:
  23. : >[...]
  24. : >Bonus question:  why does the grammer allow only the '=
  25. : >assignment-expression' form:
  26. : >[grammar to allow 'while (T t(i)) { /* ... */]
  27. : I think the general case could lead to ambiguities in parsing. If a
  28. : function call can possibly be interpreted as a variable definition, then
  29. : it is a variable definition. That could lead to unexpected behavior
  30. : which would be difficult to track down.
  31. : You can always write the same thing with "=" notation:
  32. :         while( T t = T(i) ) { ... }
  33. : This rewrite is not guaranteed to be as efficient, but most compilers
  34. : do optimize away the extra copy.
  35.  
  36. It is not the same if the copy-constructor for T is private (say, as part
  37. of preventing copying of Ts) and the constructor from the type of 'i' is
  38. public, as is the case in at least one class I have.  Then only the 'T
  39. t(i)' form is legal.
  40.     --scott
  41. ---
  42. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  43.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  44.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  45.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  46.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  47. ]
  48.